package org.xtext.ic.dsl.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import org.xtext.ic.dsl.icDsl.Attribute;
import org.xtext.ic.dsl.icDsl.Connection;
import org.xtext.ic.dsl.icDsl.CreateDAO;
import org.xtext.ic.dsl.icDsl.DataBase;
import org.xtext.ic.dsl.icDsl.Entity;
import org.xtext.ic.dsl.icDsl.Flags;
import org.xtext.ic.dsl.icDsl.IcDslPackage;
import org.xtext.ic.dsl.icDsl.Layer;
import org.xtext.ic.dsl.icDsl.Model;
import org.xtext.ic.dsl.icDsl.PackagePrefix;
import org.xtext.ic.dsl.icDsl.TypeDef;
import org.xtext.ic.dsl.services.IcDslGrammarAccess;

@SuppressWarnings("all")
public class IcDslSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private IcDslGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == IcDslPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case IcDslPackage.ATTRIBUTE:
				if(context == grammarAccess.getAttributeRule()) {
					sequence_Attribute(context, (Attribute) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.CONNECTION:
				if(context == grammarAccess.getConnectionRule()) {
					sequence_Connection(context, (Connection) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.CREATE_DAO:
				if(context == grammarAccess.getCreateDAORule()) {
					sequence_CreateDAO(context, (CreateDAO) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.DATA_BASE:
				if(context == grammarAccess.getDataBaseRule()) {
					sequence_DataBase(context, (DataBase) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.ENTITY:
				if(context == grammarAccess.getEntityRule() ||
				   context == grammarAccess.getTypeRule()) {
					sequence_Entity(context, (Entity) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.FLAGS:
				if(context == grammarAccess.getFlagsRule()) {
					sequence_Flags(context, (Flags) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.LAYER:
				if(context == grammarAccess.getLayerRule() ||
				   context == grammarAccess.getTypeRule()) {
					sequence_Layer(context, (Layer) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.MODEL:
				if(context == grammarAccess.getModelRule()) {
					sequence_Model(context, (Model) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.PACKAGE_PREFIX:
				if(context == grammarAccess.getPackagePrefixRule()) {
					sequence_PackagePrefix(context, (PackagePrefix) semanticObject); 
					return; 
				}
				else break;
			case IcDslPackage.TYPE_DEF:
				if(context == grammarAccess.getTypeRule() ||
				   context == grammarAccess.getTypeDefRule()) {
					sequence_TypeDef(context, (TypeDef) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     ((one?='one' | many?='many')? type=[Type|ID] name=ID flags=Flags?)
	 */
	protected void sequence_Attribute(EObject context, Attribute semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         (
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             user=STRING? 
	 *             password=STRING? 
	 *             url=STRING? 
	 *             port=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             dbname=STRING 
	 *             type=DataBase 
	 *             user=STRING? 
	 *             password=STRING? 
	 *             url=STRING? 
	 *             port=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             user=STRING 
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             password=STRING? 
	 *             url=STRING? 
	 *             port=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             password=STRING 
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             user=STRING? 
	 *             url=STRING? 
	 *             port=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             url=STRING 
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             user=STRING? 
	 *             password=STRING? 
	 *             port=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             port=STRING 
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             user=STRING? 
	 *             password=STRING? 
	 *             url=STRING? 
	 *             poolsize=STRING?
	 *         ) | 
	 *         (
	 *             poolsize=STRING 
	 *             type=DataBase 
	 *             dbname=STRING 
	 *             user=STRING? 
	 *             password=STRING? 
	 *             url=STRING? 
	 *             port=STRING?
	 *         )
	 *     )
	 */
	protected void sequence_Connection(EObject context, Connection semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (basedao?='base-dao'? daolayer=[Layer|ID]? firstEntity=[Entity|ID] entities+=[Entity|ID]*)
	 */
	protected void sequence_CreateDAO(EObject context, CreateDAO semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (mysql?='MySQL' | sqlserver?='SQL Server' | oracle?='Oracle')
	 */
	protected void sequence_DataBase(EObject context, DataBase semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID superEntity=[Entity|ID]? attributes+=Attribute*)
	 */
	protected void sequence_Entity(EObject context, Entity semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (id?='id' autoid?='auto-increment'?)
	 */
	protected void sequence_Flags(EObject context, Flags semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID connection=Connection? createdao=CreateDAO? types+=Type*)
	 */
	protected void sequence_Layer(EObject context, Layer semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (package=PackagePrefix? connection=Connection? createdao=CreateDAO? types+=Type*)
	 */
	protected void sequence_Model(EObject context, Model semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     name=JAVAID
	 */
	protected void sequence_PackagePrefix(EObject context, PackagePrefix semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, IcDslPackage.Literals.PACKAGE_PREFIX__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, IcDslPackage.Literals.PACKAGE_PREFIX__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getPackagePrefixAccess().getNameJAVAIDParserRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID mappedType=JAVAID?)
	 */
	protected void sequence_TypeDef(EObject context, TypeDef semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
}
